Skip to content

fix: subtract trailing padding in editor intrinsic size computations - #2749

Open
ndelanou wants to merge 1 commit into
singerdmx:masterfrom
ndelanou:fix/container-box-intrinsics-padding
Open

fix: subtract trailing padding in editor intrinsic size computations#2749
ndelanou wants to merge 1 commit into
singerdmx:masterfrom
ndelanou:fix/container-box-intrinsics-padding

Conversation

@ndelanou

@ndelanou ndelanou commented Jul 7, 2026

Copy link
Copy Markdown

Description

RenderEditableContainerBox's four intrinsic size computations resolve the child's cross extent as:

width - _resolvedPadding!.left + _resolvedPadding!.right

i.e. the leading padding is subtracted but the trailing padding is added (missing parentheses). With symmetric padding the children are measured at the full, undeflated extent, while performLayout correctly deflates both sides.

Concretely, for a QuillEditor with padding: EdgeInsets.symmetric(horizontal: 12) placed under IntrinsicHeight (a typical message-composer layout), text is measured 24px wider than it is laid out: a word that wraps onto a new line at layout width still fits at measure width, so the intrinsic height is exactly one line short — a RenderFlex overflowed by <one line> pixels on the bottom right at the moment a line wraps. Typing a few more characters makes the too-wide measurement wrap too and the error "heals", until the next wrap.

The fix replaces the expressions with extent - padding.horizontal / extent - padding.vertical in all four methods (computeMin/MaxIntrinsicWidth, computeMin/MaxIntrinsicHeight).

Includes a regression test in test/bug_fix_test.dart that lays out an editor with horizontal padding and asserts getMin/MaxIntrinsicHeight(width) equals the laid-out height (fails before the fix, passes after), plus a CHANGELOG.md entry.

Related Issues

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

🤖 Generated with Claude Code

RenderEditableContainerBox's computeMin/MaxIntrinsicWidth and
computeMin/MaxIntrinsicHeight computed the child extent as
'extent - padding.leading + padding.trailing' (missing parentheses), so
with symmetric padding children were measured at the undeflated extent
while performLayout deflates both sides. Under IntrinsicHeight this made
the editor's reported height one line short at the exact moment a line
wraps, overflowing composer-style layouts.

Fixes singerdmx#2748

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ndelanou
ndelanou marked this pull request as ready for review July 7, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RenderFlex overflow under IntrinsicHeight: RenderEditableContainerBox intrinsics add right/bottom padding instead of subtracting it

1 participant